from django.conf.urls import url, include
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from apps.meiduo_admin.views import admin
from apps.meiduo_admin.views import group
from apps.meiduo_admin.views import permission
from apps.meiduo_admin.views import spus
from apps.meiduo_admin.views.admin import AdminView
from apps.meiduo_admin.views.group import GroupViewSet
from apps.meiduo_admin.views.images import ImageView
from apps.meiduo_admin.views.orders import OrderInfoView
from apps.meiduo_admin.views.permission import PermissionViewSet
from apps.meiduo_admin.views.skus import SKUSModelViewSet
from apps.meiduo_admin.views.spu_specs import SPUSpecsModelViewSet
from .views import statistical, user, skus

urlpatterns = [
    url(r'^authorizations/$', obtain_jwt_token),
    # 统计相关
    url(r'^statistical/total_count/$', statistical.UserAllCountAPIView.as_view()),
    url(r'^statistical/day_increment/$', statistical.UserDailyCountAPIView.as_view()),
    url(r'^statistical/day_active/$', statistical.UserDailyActiveCountView.as_view()),
    url(r'^statistical/day_orders/$', statistical.UserDailyOrderCountView.as_view()),
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    url(r'^statistical/goods_day_views/$', statistical.UserCategoryCountAPIView.as_view()),
    # 用户查询相关
    url(r'^users/$', user.UserListCreateAPIView.as_view()),
    # 商品查询相关
    url(r'^skus/categories/$', skus.SKUSimpleCategoryListAPIView.as_view()),
    url(r'^goods/simple/$', skus.SPUSimpleListAPIView.as_view()),
    url(r'^goods/(?P<pk>\d+)/specs/$', spus.SPUSpecView.as_view()),
    # 图片查询相关
    url(r'^skus/simple/$', skus.SKUSimpleListView.as_view()),
    url(r'^permission/content_types/$', permission.ContentTypeListView.as_view()),
    url(r'^permission/simple/$', group.PermissionSimpleListView.as_view()),
    url(r'^permission/groups/simple/$', admin.GroupSimpleView.as_view()),


]

router = DefaultRouter()
router.register(r'skus/images', ImageView, base_name='images')
urlpatterns += router.urls

router = DefaultRouter()
router.register(r'skus', SKUSModelViewSet, base_name='skus')
urlpatterns += router.urls

router = DefaultRouter()
router.register(r'orders', OrderInfoView, base_name='orders')
urlpatterns += router.urls

router = DefaultRouter()
router.register(r'permission/perms', PermissionViewSet, base_name='perms')
urlpatterns += router.urls

router = DefaultRouter()
router.register(r'permission/groups', GroupViewSet, base_name='groups')
urlpatterns += router.urls

router = DefaultRouter()
router.register(r'permission/admins', AdminView, base_name='admins')
urlpatterns += router.urls
#########对spu的规格进行管理######################
router = DefaultRouter()
router.register(r'goods/specs', SPUSpecsModelViewSet, base_name='goods_specs')
urlpatterns += router.urls